package string_question.jianzhioffer.test5;

/**
 * 方法一 ： 常规解法，替换
 * @author code_yc
 * @version 1.0
 * @date 2020/7/5 9:39
 */
public class Solution1 {

    public String replaceSpace(String s) {
        if (s == null || s.length() == 0) return s;
        StringBuilder res = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == ' ') {
                res.append("%20");
            } else {
                res.append(s.charAt(i));
            }
        }
        return res.toString();
    }
}
